//
//  Product_Detail_Frame.m
//  LoveTravel
//
//  Created by MS on 16-1-25.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "Product_Detail_Frame.h"
#import "NSString+Size.h"
#define margin 10

@interface Product_Detail_Frame ()

@property (nonatomic,assign) CGFloat  tmpHeight;

@end


@implementation Product_Detail_Frame

-(void)setProductData:(ProductDetailModel *)productData
{
    _productData =  productData;
    int i  = 0;
    for (Product_Details * detail in productData.details) {
        
        if ([detail.type isEqualToString:@"head"]) {
            
            detail.content.headFrame = CGRectMake(0, margin +_tmpHeight, WIDTH, 30);
            _tmpHeight = CGRectGetMaxY(detail.content.headFrame);
            
            if (i==1) {
                _adjust_Height = _tmpHeight+10+35;
            }
            i++;
        }
        
        if ([detail.type isEqualToString:@"referrer"]) {
            detail.content.referrerFrame =CGRectMake(0, margin +_tmpHeight, WIDTH, 70);
            _tmpHeight = CGRectGetMaxY(detail.content.referrerFrame);
        }
        
        if ([detail.type isEqualToString:@"text"]) {
            
            CGSize textSize = [detail.content.text sizeWithString:CGSizeMake(WIDTH-20, CGFLOAT_MAX) Font:TEXT_FONT];
            detail.content.textFrame = CGRectMake(margin, margin +_tmpHeight, WIDTH-20, textSize.height);
             _tmpHeight = CGRectGetMaxY(detail.content.textFrame);
        }
        
        if ([detail.type isEqualToString:@"pic"]) {
            
            CGFloat bi =  detail.content.width/(WIDTH-20);
            CGFloat height = detail.content.height/bi;
            detail.content.picFrame = CGRectMake(margin, margin +_tmpHeight, WIDTH-20, height);
    
            _tmpHeight = CGRectGetMaxY(detail.content.picFrame);
        }
        
        
    }
    
    self.contenView_Height = _tmpHeight;

}

@end
